from enum import Enum
from ipaddress import IPv4Address
from pydantic import BaseModel, UUID4
from settings import settings


class Device(BaseModel):
    ip: IPv4Address = IPv4Address('10.16.0.201')
    port: int = 3000
    netmask: IPv4Address = IPv4Address('255.255.255.0')
    gateway: IPv4Address = IPv4Address('10.16.0.1')


class Server(BaseModel):
    name: str = 'server name'
    ip: str = '10.16.0.140'
    proxy_ip: str = '10.16.0.140'
    port: int = 5001


class Module(BaseModel):
    serial_number: str = '004-02 2301 01'
    device_name: str = 'device name'
    mac_address: str = '00:b0:33:ff:f8:00'


class ChanelConfig(str, Enum):
    LTE = 'LTE'
    GSM = 'GSM'
    LTE_GSM = 'LTE_GSM'


class CalibrationState(str, Enum):
    CALIBRATED = 'CALIBRATED'
    CALIBRATION_FAILED = 'CALIBRATION_FAILED'
    UNCALIBRATED = 'UNCALIBRATED'


class UnitConfiguration(BaseModel):
    timezone: int = 4
    device: Device = Device()
    server: Server = Server()

    main_module: Module = Module()

    retry: int = 1
    interval: int = 15  # in seconds

    unit_type: str = 'FSC'
    block_name: str = 'block name'
    alarms_enabled: bool = False  # not used
    auto_gain_enabled: bool = False   # not used

    version_info: str = settings.APP_VERSION

    channel_3_and_4_config: ChanelConfig = ChanelConfig.GSM

    ustirovka_state: bool = False
    simulation_state: bool = False
    calibration_state: CalibrationState = CalibrationState.UNCALIBRATED

    ac_link_tx: bool = False
    ac_link_rx: bool = False
    ac_service_tx: bool = False

    acc_base_power_calibrate: bool = False
    acc_link_calibrate: bool = False
    acc_tx_service_calibrate: bool = False

    cviya: str = 'ЦВИЯ.464117.004-02'
    uuid: str = 'd0ded0de-d0de-d0de-d0de-d0ded0ded0de'
